package apiday03;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
// 新循环的演示
public class NewForDemo {
    public static void main(String[] args) {
        String[] array = {"one","two","three","four","five"};
        for (int i=0;i<array.length;i++){
            System.out.println(array[i]);
        }

        for (String str : array){
            System.out.println(str);
        }

        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator it = c.iterator();
        System.out.println(c);
        while (it.hasNext()){
            String str = (String) it.next();
            System.out.println("元素:"+str);
        }

        for (Object obj : c){
            String str = (String) obj;
            System.out.println(str);
        }

        /*
        Collection cc = new ArrayList();
        cc.add("hello");
        c.add(new Integer(5));
        c.add(new Point(1,2));
         */
    }
}
